package component

import (
	"fmt"
	"github.com/asaskevich/EventBus"
	"gorm.io/gorm"
	"os"
	"path/filepath"
	"regexp"
)

var Db *gorm.DB

var DefaultEventBus = EventBus.New()

var rootPath string

func init() {
	setRootPath()
	loadConfig()
	initLog()
	initMysql()
	initMsgLog()
}

func setRootPath() {
	currentDir, err := os.Getwd()
	if err != nil {
		fmt.Println("获取当前目录失败:", err)
		panic(err)
	}
	//测试切换到跟目录
	re, _ := regexp.Compile("[\\\\|\\/]test")
	rootPath = re.ReplaceAllString(currentDir, "") + string(filepath.Separator)
}
